home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_052 / tek4010 / defaults.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  107 lines

  1. /***************************************************************
  2.  * vt100 - terminal emulator - initialization
  3.  *
  4.  *           Oct-86 TAW - use preferences baud rate only, and
  5.  *            - other inutition based mods.
  6.  *           860823 DBW - Integrated and rewrote lots of code
  7.  *      v2.0 860809 DBW - Major rewrite
  8.  *      v1.1 860720 DBW - Switches, 80 cols, colors, bug fixes
  9.  *      v1.0 860712 DBW - First version released
  10.  *
  11.  ***************************************************************/
  12.  
  13. #include "vt100.h"
  14.  
  15. void InitDefaults (argc, argv)
  16.  
  17. char **argv;
  18. int  argc;
  19. {
  20.     FILE    *fd;
  21.     extern void ReadDefaults ();
  22.  
  23.     if (((argc > 1) && (fd=fopen(argv[1],"r")) != 0) ||
  24.         (fd=fopen("vt100.init","r")) != 0 ||
  25.         (fd=fopen("c:vt100.init","r")) != 0) {
  26.             ReadDefaults(fd);
  27.             fclose(fd);
  28.             }
  29.  
  30.     /* Now set up all the screen info as necessary */
  31.         MINY = 14;
  32.     p_lines = 24;
  33.         NewWindow.Height    = (long)((p_lines*8)+8);
  34.  
  35.     NewWindow.MinHeight = NewWindow.Height;
  36.     NewWindow.MaxHeight = NewWindow.Height;
  37.     NewWindow.TopEdge   = 3;
  38.     MAXY = ((p_lines-1)*8) + MINY;
  39.     top  = MINY;
  40.     bot  = MAXY;
  41.     savx = MINX;
  42.     savy = MINY;
  43.         NewWindow.TopEdge       = 0;
  44.         NewWindow.Screen        = NULL;
  45.         NewWindow.Type  = WBENCHSCREEN;
  46. }
  47.  
  48. /*****************************************************************
  49. *
  50. * this function reads the file that contains the user defaults if
  51. * the file was opened by InitDefault, it then modifies the p_ variables
  52. * to the new values. This code is based on DBW's code, but I changed it
  53. * a little, by removing a few things that I did not use.
  54. *
  55. * T Whelan Sept 1986
  56. *
  57. ******************************************************************/
  58.  
  59. extern char *malloc();
  60.  
  61. void
  62. ReadDefaults(fd)
  63. FILE *fd;
  64. {
  65.     char    c0, delim, line[256], macro[256], *ptr;
  66.     int     i, j, k;
  67.  
  68.         while (fgets(line,256,fd) != 0) {
  69.             if ((c0 = line[0]) == '#') continue;
  70.             if ((c0|' ') == 'e') break;
  71.             if (sscanf(&line[1],"%d",&i) != 1) continue;
  72.             if (i < 1 || i > 10) continue;
  73.             delim = 0;
  74.             for (j=3; line[j] != 0 &&
  75.                      (line[j] == ' ' || line[j] == '\t'); j++) ;
  76.                if (line[j] == 0) {
  77.                   if (c0 == 'f') p_f[i-1] = NULL;
  78.                    else          p_F[i-1] = NULL;
  79.                    break;
  80.                    }
  81.               delim = line[j];
  82.               k = 0;
  83.               macro[0] = 0;
  84.               while (line[++j] != delim) {
  85.                  if (line[j] == 0) {
  86.                     if (fgets(line,256,fd) == 0) {
  87.                         line[0] = delim;
  88.                         line[1] = 0;
  89.                         }
  90.                         j = -1;
  91.                         continue;
  92.                      }
  93.                      if (line[j] == '^' && line[++j] != '^')
  94.                          macro[k++] = (line[j]|' ') - 0x60;
  95.                       else if (line[j] != '\n') macro[k++] = line[j];
  96.                          macro[k]   = 0;
  97.               }
  98.               ptr = malloc(k+1);
  99.               if (c0 == 'f') p_f[i-1] = ptr;
  100.               else           p_F[i-1] = ptr;
  101.               strcpy(ptr,macro);
  102.             }
  103. }
  104.  
  105.  
  106.  
  107.